package com.rongxun.hbwallet.mvp.presenter;

import android.support.annotation.NonNull;

import com.rongxun.base.BasePresenter;
import com.rongxun.base.ResponseSubscriber;
import com.rongxun.hbwallet.constants.SPKey;
import com.rongxun.hbwallet.model.bean.Token;
import com.rongxun.hbwallet.mvp.contract.IMain;
import com.rongxun.utils.PreferenceUtils;

/**
 * 创建者     庄丰泽
 * 创建时间   2018/5/18 13:42
 * 描述
 */

public class MainPresenter extends BasePresenter<IMain.IView, IMain.IModel> implements IMain.IPresenter {


    public MainPresenter(@NonNull IMain.IView pUi, @NonNull IMain.IModel pModel) {
        super(pUi, pModel);
    }

    @Override
    public void refreshToken() {
        addSubscribe(getModel().refreshToken().subscribeWith(new ResponseSubscriber<Token>(getView()) {
            @Override
            public void onSuccess(Token token) {
                PreferenceUtils.putString(SPKey.TOKEN, token.getToken());
            }
            @Override
            public void disposeEorCode(String message, String code) {
            }
        }));
    }
}
